// src/router/index.js
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Home from '@/views/elderly/Home.vue'
import VolunteerHome from '@/views/volunteer/VolunteerHome.vue'

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    redirect: '/index',
    children: [
      { path: '/user', component: () => import('../views/user/UserView.vue') },
      { path: 'index', component: () => import('../views/IndexView') },
      { path: '/register/service', component: () => import('../views/register/ServiceUserRegister.vue') }
    ]
  },

  { path: '/login', component: () => import('../views/LoginView') },

  {
    path: '/guide',
    component: () => import('../views/Guide/GuideView.vue'),
    meta: { requiresAuth: true }
  },

  /* 老人模块路由 */
  {
    path: '/elderly',
    name: 'elderlyHome',
    component: Home,
    redirect: '/elderly/user-info',
    children: [
      { path: 'user-info', component: () => import('../views/elderly/InfoPage.vue') },
      { path: 'social', component: () => import('../views/elderly/SocialPage.vue') },
      { path: 'entertainment', component: () => import('../views/elderly/EntertainmentPage.vue') },
      { path: 'medication', component: () => import('../views/elderly/MedicationPage.vue') },
      { path: 'activity', component: () => import('../views/elderly/ActivityPage.vue') },
      { path: 'emergency', component: () => import('../views/elderly/EmergencyPage.vue') }
    ]
  },

  /* 志愿者路由 */
  { path: '/volunteer', component: () => import('../views/volunteer/VolunteerHome.vue') },
  { path: '/volunteer/account-security', component: () => import('../views/volunteer/AccountSecurity.vue') },
  { path: '/volunteer/basic-info', component: () => import('../views/volunteer/BasicInfo.vue') },
  { path: '/volunteer/notifications', component: () => import('../views/volunteer/Notifications.vue') },
  { path: '/volunteer/activity-list', component: () => import('../views/volunteer/ActivityList.vue') },
  { path: '/volunteer/my-activities', component: () => import('../views/volunteer/MyActivities.vue') },
  { path: '/volunteer/points-goods', component: () => import('../views/volunteer/PointsGoods.vue') },
  { path: '/volunteer/my-points-exchanges', component: () => import('../views/volunteer/MyPointsExchanges.vue') },

  /* 管理员路由 */
  {
    path: '/admin',
    name: 'adminHome',
    component: () => import('@/views/admin/AdminParentView.vue'),
    children: [
      { path: 'information', component: () => import('@/views/admin/AdminInformation.vue') },
      { path: 'adminList', component: () => import('@/views/admin/AdminList.vue') },
      { path: 'noticeList', component: () => import('@/views/admin/NoticeList.vue') }
    ]
  },

  /* 家属端路由 */
  {
    path: '/familyuser',
    name: 'familyHome',
    component: () => import('@/views/familyuser/FamilyUserHome.vue'),
    children: [
      { path: 'info', component: () => import('@/views/familyuser/FamilyInfo.vue') },
      { path: 'bind', component: () => import('@/views/familyuser/ElderlyBind.vue') },
      { path: 'medication', component: () => import('@/views/familyuser/MedicationReminder.vue') },
      { path: 'health', component: () => import('@/views/familyuser/HealthElderly.vue') },
      { path: 'location',name:"elderly-location", component: () => import('@/views/familyuser/liveLocation.vue') }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router